package io.renren.modules.stock.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.stock.entity.StatisticsEntity;
import io.renren.modules.stock.service.StatisticsService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 数据
 *
 * @author chenshun
 * @email 979944697@qq.com
 * @date 2022-02-27 13:46:35
 */
@RestController
@RequestMapping("stock/statistics")
public class StatisticsController {
    @Autowired
    private StatisticsService statisticsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("stock:statistics:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = statisticsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("stock:statistics:info")
    public R info(@PathVariable("id") Long id){
		StatisticsEntity statistics = statisticsService.getById(id);

        return R.ok().put("statistics", statistics);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("stock:statistics:save")
    public R save(@RequestBody StatisticsEntity statistics){
		statisticsService.save(statistics);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("stock:statistics:update")
    public R update(@RequestBody StatisticsEntity statistics){
		statisticsService.updateById(statistics);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("stock:statistics:delete")
    public R delete(@RequestBody Long[] ids){
		statisticsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
